package testiranjeSoftvera.GuiElements;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;

import testiranjeSoftvera.phage.PhageCore;

public class GameDialog extends JDialog {

	private static final long serialVersionUID = 8636415262835737254L;

	private static GameDialog instance;

	private JPanel mainPanel;
	private JPanel gamePanel;
	private JButton exitButton;

	// Pause button
	// lalal

	private GameDialog() {

		// Set values
		setModal(true);
		setTitle("Phage Game");
		setContentPane(getMainPanel());
		// Dimension screenSize = new Dimension(Toolkit.getDefaultToolkit()
		// .getScreenSize());
		// setBounds((int) screenSize.getWidth() / 2 - 600,
		// (int) screenSize.getHeight() / 2 - 450, 1200, 900);
		setSize(new Dimension(800, 600));
		setLocationRelativeTo(null);

		// pack();
	}

	public static GameDialog getInstance() {
		if (instance == null) {
			instance = new GameDialog();
		}
		return instance;
	}

	public JPanel getMainPanel() {
		if (mainPanel == null) {

			mainPanel = new JPanel(new BorderLayout());
			mainPanel.add(getGamePanel(), BorderLayout.CENTER);
			mainPanel.add(getExitButton(), BorderLayout.SOUTH);

		}
		return mainPanel;
	}

	public JPanel getGamePanel() {
		if (gamePanel == null) {
			gamePanel = new JPanel();
			JLabel labela = new JLabel("Ovde ce se igrati nesto");
			gamePanel.setBorder(BorderFactory
					.createTitledBorder("GamePanel - Phage Wars"));
			gamePanel.add(labela);
		}
		return gamePanel;
	}

	public JButton getExitButton() {
		if (exitButton == null) {

			exitButton = new GameButton("Exit game");
			exitButton.addActionListener(PhageCore.getInstance()
					.getAccManager().getExitGame());

		}
		return exitButton;
	}

}
